package dujiu.leetcode.greed;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class P1403 {
    public List<Integer> minSubsequence(int[] nums) {
        Arrays.sort(nums);
        List<Integer> list = new ArrayList<>();
        int sum = 0;
        for (int i = nums.length-1; i >= 0; i--) {
            sum += nums[i];
        }
        int total =0;
        for (int i = nums.length-1; i >= 0; i--) {
            total += nums[i];
            sum -= nums[i];
            list.add(nums[i]);
            if (total > sum){
                break;
            }
        }
        return list;
    }
}
